package com.neouton.crm.customer.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neouton.common.entity.ActivitiVO;
import com.neouton.common.util.PageUtil;
import com.neouton.crm.customer.entity.ContactsVO;
import com.neouton.crm.customer.entity.CustomerVO;
import com.neouton.crm.entity.SysUserEntity;
import com.neouton.crm.product.entity.ProductInfoVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;


@Mapper
public interface CustomerMapper {

    /**
     * 多条件分页查询客户信息列表
     * @Timestamp: 2022-11-18
     * @Author: WuJie
     * @param page 分页信息
     * @param customer 其余查询条件
     * @return 分页查询结果
     */
    IPage<CustomerVO> queryCustomerByPage(@Param("page")IPage page, @Param("customerVO")CustomerVO customer, @Param("orderBy")String orderBy, @Param("allUserInfo")List<SysUserEntity> allUserInfo);



    /**
     * 保存工商信息
     * @Timestamp: 2022-11-17
     * @Author: WuJie
     * @param customer 需更新实体
     * @return 成功失败
     */
    Boolean insertCustomer(@Param("customerVO") CustomerVO customer);

    /**
     * 更新客户信息
     * @Timestamp: 2022-11-18
     * @Author: WuJie
     * @param customer 需更新实体
     * @return 成功失败
     */
    Boolean updateCustomer(@Param("customerVO")CustomerVO customer);


    Boolean updateIsDelete(@Param("customerId")Integer customerId,@Param("lastUpdateBy")Integer lastUpdateBy,@Param("isDelete")Integer isDelete);

    /**
     * 根据部分条件查询客户信息是否存在
     * @Timestamp: 2022-11-18
     * @Author: WuJie
     * @param customer 条件封装实体类
     * @return true存在，false不存在
     */
    CustomerVO queryCustomerExit(@Param("customer") CustomerVO customer);


    Boolean updateState(@Param("customerVO")CustomerVO customer);

    /**
     * 查询并更改是否为供应商，每次刷新更新
     * @return true成功，false失败
     */
    Boolean updateIsSupplier();


    List<CustomerVO> selectCustomerByEnterpriseId(@Param("customerVO")CustomerVO customerVO, @Param("userList") List<SysUserEntity> userList);

    List<CustomerVO> selectAllCustomers();

    CustomerVO queryCustomerById(@Param("customerId")Integer customerId);

    CustomerVO queryCustomerApprovalByWorkId(@Param("workId")Integer workId);

    CustomerVO selectCustomerById(@Param("customerId")Integer customerId);

    Boolean insertContacts(@Param("contacts")List<ContactsVO> contacts);

    List<CustomerVO> selectAllEnterprise();

    Boolean updateContacts(@Param("contacts")List<ContactsVO> contacts);

    Boolean deleteContacts(@Param("customerId")Integer customerId);

    List<CustomerVO> queryAllCusotmer(@Param("customerVO")CustomerVO customerVO,@Param("allUserInfo")List<SysUserEntity> allUserInfo);

    List<CustomerVO> queryTodoCustomerByApprovalId(@Param("approvalId") Integer approvalId);

    List<CustomerVO> selectCustomerByName(@Param("customerName")String customerName);

    List<ContactsVO> queryAllContacts();

    void backCustomerData(@Param("customerVO")CustomerVO customerVO);

    void backContactsData(@Param("customerVO")CustomerVO customerVO);

    List<CustomerVO> queryHistoryCustomerByApprovalId(Integer approvalId);

    Boolean forbiddenCustomerByApplyId(@Param("approvalId")Integer approvalId, @Param("userId")Integer userId, @Param("isDelete")Integer isDelete);

    IPage<CustomerVO> getCustomerToDoList(@Param("page")IPage page, @Param("customerVO")CustomerVO customer,@Param("orderBy")String orderBy, @Param("activitiVOS")List<ActivitiVO> activitiVOS);

    IPage<CustomerVO> getCustomerDoneList(@Param("page")IPage page, @Param("customerVO")CustomerVO customer,@Param("orderBy")String orderBy);

    IPage<CustomerVO> getCustomerRecordsList(@Param("page")IPage page, @Param("customerVO")CustomerVO customer,@Param("orderBy")String orderBy,@Param("userList")List<SysUserEntity> userList);

    Boolean updatePessorId(@Param("userId")Integer userId, @Param("customer")List<CustomerVO> customer);

    void backCustomerListData(@Param("customer")List<CustomerVO> customer);

    CustomerVO getCustomerDocumentaryViewInfo(Integer customerId);

    List<ContactsVO> selectBackContactsByCustomerID(@Param("customerVOS")CustomerVO customerVOS);
}
